<extend name="Public/base" />

<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>商品列表</h2>
    </div>
    <div class="cf">
        <div class="fl">
            <a class="btn" href="{:U('manage_add')}">新 增</a>
            <!-- <button class="btn sc"  target-form="ids">删 除</button> -->
        </div>

        <!-- 高级搜索 -->
        <div>
        <form action="{:U(Manage/floor_index}" method="post">
        <table>
            <tr>
                <td>&nbsp&nbsp&nbsp</td>
                <td>
                    创建时间:&nbsp&nbsp
                </td>
                <td>
                    <input type="text" id="test1" name="begin_time" value="{$msg.begin_time}" style="border:1px solid #ccc;border-radius:5px;height:26px;line-height:26px;">——
                    <input type="text" id="test2" name="end_time" value="{$msg.end_time}" style="border:1px solid #ccc;border-radius:5px;height:26px;line-height:26px;">
                </td>
                <td>&nbsp&nbsp&nbsp</td>
                <td>
                    楼盘名搜索:&nbsp&nbsp
                </td>
                <td>
                    <input type="text" name="name" value="{$msg.name}" style="border:1px solid #ccc;border-radius:5px;height:26px;line-height:26px;">
                </td>
                <td>&nbsp
                    <input type="submit" value="搜索" class="btn">
                </td>
            </tr>
        </table>
</form>
        </div>
    </div>
    <!-- 数据列表 -->
    <div class="data-table table-striped">
    <table class="">
    <thead>
        <tr>
        <th class="row-selected row-selected"><input class="check-all" type="checkbox"/></th>
        <th class="">商品编号</th>
        <th class="">图片</th>
        <th class="">商品名称</th>
        <th class="">所属店铺</th>
        <th class="">总销量</th>
        <th class="">分类</th>
        <th class="">时间</th>
        <th class="">状态</th>
        <th class="">商品详情</th>
        <th class="">操作</th>
        </tr>
    </thead>
    <tbody>
        <notempty name="list">
        <volist name="list" id="vo">
        <tr>
            <td><input class="ids" type="checkbox" name="id[]" value="{$vo.id}" /></td>
            <td>{$vo.id} </td>
            <td><img src="{$vo.img}" height="30" width="30"></td>
            <td>{$vo.name} </td>
            <td>{$vo.shop_name} </td>
            <td>{$vo.count} </td>
            <td>{$vo.type_name} </td>
            <td>{$vo.create_time}</td>
            <td>{$vo.disablee} </td>
            <td><a href="{:U('Manage/good_detail?method=resumeUser&id='.$vo['id'])}" class="">详情</a></td>
            <td>
			    <if condition="$vo['recommend'] eq 1">
                    <a onclick="recommend('{$vo.id}',1)" style="cursor:pointer;">推荐</a>
                    <else/>
                    <a onclick="recommend('{$vo.id}',2)" style="cursor:pointer;">已推荐</a>
                </if>

                <if condition="$vo['disable'] eq 1">
                    <a onclick="disable('{$vo.id}',1)" style="cursor:pointer;">下架</a>
                    <else/>
                    <a onclick="disable('{$vo.id}',2)" style="cursor:pointer;">上架</a>
                </if>


                <a onclick="ss('{$vo.id}',1)" style="cursor:pointer;">删除</a>


            </td>
        </tr>
        </volist>
        <else/>
        <td colspan="9" class="text-center"> aOh! 暂时还没有内容! </td>
        </notempty>
    </tbody>
    </table>
    </div>
    <div class="page">
        {$_page}
    </div>
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.thinkbox.js"></script>

    <script src="__JS__/laydate/laydate.js"></script>
    <script type="text/javascript">
    laydate.render({
      elem: '#test1' //指定元素
      ,type: 'datetime'
    });
    laydate.render({
      elem: '#test2' //指定元素
      ,type: 'datetime'
    });
    //搜索功能
    $("#search").click(function(){
        var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
        window.location.href = url;
    });
    //回车搜索
    $(".search-input").keyup(function(e){
        if(e.keyCode === 13){
            $("#search").click();
            return false;
        }
    });


		function recommend(id,value){
            var a=id;
            var b=value;
            $.ajax({
                url:"{:U('Manage/recommend')}",
                data:{'id':a,'recommend':b},
                type:'post',
                dataType:'json',
                success:function(data){
                    alert(data.info);
                    // window.location.reload();
                    location.replace(location.href);
                },

            });
        }

        function disable(id,value){
            var a=id;
            var b=value;
            $.ajax({
                url:"{:U('Manage/g_disable')}",
                data:{'id':a,'disable':b},
                type:'post',
                dataType:'json',
                success:function(data){
                    alert(data.info);
                    // window.location.reload();
                    location.replace(location.href);
                },

            });
        }

function ss(id){
var id=id;
if(confirm('确定删除吗？？？')){
    $.ajax({
        url:"{:U('Manage/good_del')}",
        data:{'id':id},
        dataType:'json',
        type:'post',
        success:function(data){
            alert(data.info);
            window.location.reload();
        }
    })
}
    }

    //导航高亮
    highlight_subnav('{:U('User/index')}');
    </script>
</block>




